<?php
declare (strict_types = 1);

namespace app\controller;

use app\model\User;
class Followers
{
    protected $middleware = [
        \app\middleware\Auth::class  => ['only' => ['save','delete'] ], ];
    public function save($id)
    {
        $userArr=loginUser();
        $user=User::find($userArr['id']);
        $user->follower($id);
        return redirect((string) url('User/read',['id'=>$id]))->with('success','已成功关注该用户');
    }
    public function delete($id){

        $userArr=loginUser();
        $user=User::find($userArr['id']);
        $user->unfollower($id);
        return redirect((string) url('User/read',['id'=>$id]))->with('success','已取消关注该用户');
    }

}
